// 导入http模块
const http = require('http')

// 创建服务
const server = http.createServer((request, response) => {
  response.setHeader('Content-Type', 'text/html;charset=utf-8')
  const { pathname } = new URL(request.url, 'http://localhost:9000')
  const { method } = request
  if (method === 'GET' && pathname === '/login') {
    // 登录
    response.end('<h1>登录</h1>')
  } else if (method === 'GET' && pathname === '/register') {
    // 注册
    response.end('<h1>注册</h1>')
  } else {
    response.end('<h1>Not Found</h1>')
  }
})

// 监听服务
server.listen(9000, () => {
  console.log(`
      _   _            _     
     | \\ | | ___   ___ | |  ___
     |  \\| |/ _ \\ / _ \\| |/ (_) \\
     | |\\  | (_) | (_) | | —————
     |_| \\_|\\___/ \\___/|_|\\ ____
    
    ✨ Node.js Server ✨ is up and running!
    Visit: http://localhost:9000
  `);
})